import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _regeneratorRuntime from "@babel/runtime/regenerator";

/*
 * secGrpAuthorityPurorg - 分配安全组-数据权限tab页 - 采购组织 - model
 * @date: 2019-12-23

 */
import { createPagination, getResponse } from 'utils/utils';
import { queryData } from "../../services/roleManagementService";
export default {
  namespace: 'secGrpAuthorityPurorg',
  state: {
    list: [],
    // 请求查询到的数据
    pagination: {} // 分页信息

  },
  effects: {
    fetchAuthorityPurorg: /*#__PURE__*/_regeneratorRuntime.mark(function fetchAuthorityPurorg(_ref, _ref2) {
      var payload, call, put, response, data;
      return _regeneratorRuntime.wrap(function fetchAuthorityPurorg$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              payload = _ref.payload;
              call = _ref2.call, put = _ref2.put;
              _context.next = 4;
              return call(queryData, payload);

            case 4:
              response = _context.sent;
              data = getResponse(response);

              if (!data) {
                _context.next = 9;
                break;
              }

              _context.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  list: data.secGrpDclLineList.content,
                  pagination: createPagination(data.secGrpDclLineList)
                }
              });

            case 9:
            case "end":
              return _context.stop();
          }
        }
      }, fetchAuthorityPurorg);
    })
  },
  reducers: {
    updateState: function updateState(state, _ref3) {
      var payload = _ref3.payload;
      return _objectSpread(_objectSpread({}, state), payload);
    }
  }
};